var groupObj = {
    userid: "",
    lTeamId: "",
    init: function() {
        this.userid = $.cookie('userid');
        this.lTeamId = publicObj.getUrlData("lTeamId");
        this.getGroupInfor();
        this.tooDetail();
    },
    //拼团信息
    getGroupInfor: function() {
        var me = this;
        var url = magic_config.urlPrefix + 'GroupbuyService/getallgroupbuyinfo';
        var sUserIdStr;
        if (me.userid == null) {
            sUserIdStr = "";
        } else {
            sUserIdStr = me.userid;
        }
        var data = {
            lTeamId: me.lTeamId,
            sUserId: sUserIdStr
        }
        console.log(data);
        $.ajax({
            url: url,
            type: 'get',
            data: data,
            async: false,
            dataType: 'json',
            success: function(res) {
                var nCode = res.return.nCode;
                if (nCode === 0) {
                    //console.log(res.response);
                    me.splitGroupinfor(res.response);
                } else {
                    console.log("数据请求失败，后到前");
                }
            },
            error: function(res) {
                console.log("数据请求失败，前到后");
            }
        });
    },
    splitGroupinfor: function(resObj) {
        var str = '';
        var groupList = resObj.cdoDataList;
        var groulpCount =resObj.cdoData.nCountPerGroup;
        console.log(resObj);
        for (var i = 0; i < groulpCount; i++) {
            if (i == 0) {
                str += '<div class="userimgwall"><div class="userimg"><img src="' + groupList[i].sUserPhoto + '" alt="" /></div><div class="leader">拼主</div></div>';
            } else {
                if (i < groupList.length) {
                    str += '<div class="userimgwall"><div class="userimg"><img src="' + groupList[i].sUserPhoto + '" alt="" /></div></div>';
                } else {
                    str += '<div class="userimgwall"><div class="userimg userimg2"><img src="./img/himg.png" alt=""></div></div>';
                }
            }
        }
        $('.userimgbox').html(str);
        $(".gsuctxt").html('快去'+resObj.cdoData.sCorpName+'购物吧')
    },
    //查看订单详情
    tooDetail: function() {
        $(".togroupdetail").bind("click", function() {
            location.href = 'gdetail.html';
        })
    },

}
groupObj.init();